/**
 * Copyright (c) 2018-2025, NXOS Development Team
 * SPDX-License-Identifier: Apache-2.0
 * 
 * Contains: trace event
 * 
 * Change Logs:
 * Date           Author            Notes
 * 2025-05-17     JasonHu           Init
 */

#ifndef __NXOS_TRACE_H__
#define __NXOS_TRACE_H__

#include <nxos/xbook.h>
#include <nxos/process.h>

#ifdef __cplusplus
extern "C" {
#endif

/* 8*3+data */
typedef struct NX_EventHeader
{
    NX_U32 id;
    NX_U16 version;
    NX_U8 level;
    NX_U8 optcode;
    NX_U32 task;
    NX_U32 keyword;
    NX_U64 time;
} NX_EventHeader;

#define NX_EVENT_RECORD_SIZE 128
#define NX_EVENT_RECORD_DATA_SIZE (NX_EVENT_RECORD_SIZE - sizeof(NX_EventHeader))

#define NX_EVENT_RECORD_MAX_NR 32

struct NX_EventRecord
{
    NX_EventHeader header;
    NX_U8 data[NX_EVENT_RECORD_DATA_SIZE];
};
typedef struct NX_EventRecord NX_EventRecord;

typedef enum NX_TraceFilter {
    NX_TRACE_FILTER_FIRST = 0,
    NX_TRACE_FILTER_VER = NX_TRACE_FILTER_FIRST,
    NX_TRACE_FILTER_LEVEL,
    NX_TRACE_FILTER_TASK,
    NX_TRACE_FILTER_KEY,
    NX_TRACE_FILTER_NR
} NX_TraceFilter;

#define NX_TRACE_SET_FILTER 1
#define NX_TRACE_CLEAR_FILTER 2
#define NX_TRACE_RESET_FILTER 3

typedef struct NX_TraceFilterBuf {
    NX_TraceFilter filter;
    NX_U32 value;
} NX_TraceFilterBuf;

#ifdef __cplusplus
}
#endif

#endif  /* __NXOS_TRACE_H__ */
